import axios from '@/utils/request.js'

let message_prefix_url = "/message-server"

//获取平台配置需要的字段
export function getConfigField(platform) {
    return axios({
        url: message_prefix_url + '/config/' + platform + '/getFields',
        method: 'get'
    })
}

//删除配置通过id
export function deleteConfigById(configId) {
    return axios({
        url: message_prefix_url + '/config/deleteById?configId='+ configId,
        method: 'get'
    })
}


//获取支持的平台类型
export function getPlatform(platform) {
    return axios({
        url: message_prefix_url + '/config/platform',
        method: 'get'
    })
}


//获取某一种平台类型的所有配置
export function list(platform) {
    return axios({
        url: message_prefix_url + '/config/list?platform=' + platform,
        method: 'get'
    })
}

//添加/修改平台配置
export function addOrUpdated(updateConfigForm) {
    return axios({
        url: message_prefix_url + '/config/addOrUpdated',
        method: 'post',
        data: updateConfigForm
    })
}

//分页查询平台配置
export function pageConfig(queryConfigForm) {
    return axios({
        url: message_prefix_url + '/config/page',
        method: 'post',
        data: queryConfigForm
    })
}

//获取某一种平台的所有消息类型
export function getPlatformType(platform) {
    return axios({
        url: message_prefix_url + '/msg/type?platform=' + platform,
        method: 'get'
    })
}

//获取某一种消息类型的字段
export function getMessageField(messageType) {
    return axios({
        url: message_prefix_url + '/msg/field?messageType=' + messageType,
        method: 'get'
    })
}

//发送消息
export function msgPush(param) {
    return axios({
        url: message_prefix_url + '/msg/push',
        method: 'post',
        data: param
    })
}

//上传邮箱附件
//发送消息
export function emailUpload(formData ) {
    return axios({
        url: message_prefix_url + '/file/upload',
        method: 'post',
        headers: {"Content-Type": "multipart/form-data"},
        data: formData 
    })
}